<style scoped>
.login_verify{
        display: flex;
        flex-direction: row;
    }
</style>

<template>
    <div class="login_verify">
        <el-input v-model="verify_code" placeholder="VerifyCode" style="margin-bottom:10px"></el-input>
        <el-button type="primary" @click="sendEmail">获取验证码</el-button>
    </div>     
</template>

<script>
import { baseURL } from '../../config'
import axios from 'axios';
export default {
    name: 'verify',
    props: {
        username: [String]
    },
    data(){
        return{
            verify_code: ''
        }
    },
    methods: {
        sendEmail(){
            let args = {
                username: this.username
            }
            axios({
                method: 'post',
                url: baseURL+'/account/email',
                data: args
            }).then(res=>{
                sessionStorage.setItem("code",res.data.data);
            }).catch(error=>{
                this.$message.error("其他服务器"+error);
            })
        },
        checkCode(){
            let code = sessionStorage.getItem('code');
            if (code === this.verify_code){
                return true;
            }
            return false;
        }
    }
}
</script>